const tencentcloud = require("tencentcloud-sdk-nodejs");

const CvmClient = tencentcloud.cvm.v20170312.Client;

module.exports = {
  refreshUrl(options) {
    console.log(options)
    const paths = options.path
    const dirs = options.dir
    const secretId = options.secretId || process.env.SECRET_ID
    const secretKey = options.secretKey || process.env.SECRET_KEY
    if(!paths && !dirs) {
      throw new Error('--path和--dir为空，两者必须选一')
    }
    if(!secretId) {
      throw new Error('未设置secretId')
    }
    if(!secretKey) {
      throw new Error('未设置secretKey')
    }
    const clientConfig = {
      credential: {
        secretId: secretId || process.env.SECRET_ID,
        secretKey: secretKey || process.env.SECRET_KEY,
      },
      region: "",
      profile: {
        httpProfile: {
          endpoint: "cvm.tencentcloudapi.com",
        },
      },
    };

    const client = new CvmClient(clientConfig);
    const params = {};

    client.DescribeZones(params).then(
      (data) => {
        console.log(data);
      },
      (err) => {
        console.error("error", err);
      }
    );
  }
}
